package com.spsy.order.controller;

import com.spsy.common.core.utils.R;
import com.spsy.cpmmon.PayVo;
import com.spsy.order.domain.TOrder;
import com.spsy.order.service.ITOrderService;
import com.spsy.order.vo.OrderEnum;
import com.spsy.pay.api.PayApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: Kyrie Irving
 * @Date: 2025/10/7 19:15
 * @Description:
 **/
@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private ITOrderService itOrderService;
    
    @Autowired
    private PayApi payApi;

    @PostMapping("/createOrder")
    public R createOrder(@RequestBody PayVo payVo){
        TOrder tOrder = TOrder.builder().orderNo(payVo.getOrderId()).userId("1").orderStatus(Long.valueOf(OrderEnum.NOT_PAY.getStatusValue())).build();
        itOrderService.insertTOrder(tOrder);
        payApi.createPay(payVo);
        return R.OK();
    }
}
